package com.mewpipe.dao.jpa;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import com.mewpipe.dao.LnkCommentVideoDao;
import com.mewpipe.entity.LnkCommentVideo;


public class JpaLnkCommentVideoDao implements LnkCommentVideoDao{
private EntityManagerFactory emf;
	


	public JpaLnkCommentVideoDao(EntityManagerFactory emf) {
	
			this.emf = emf;
		
			}
	@Override
	public void addLink(long _IdComment, long _IdVideo) {
		EntityManager em = emf.createEntityManager();
		LnkCommentVideo newlink = new LnkCommentVideo(_IdComment,_IdVideo);
		
		
		try {
			em.getTransaction().begin();
			em.persist(newlink);
			em.getTransaction().commit();
			
		} 
		
		
		finally {
			if(em.getTransaction().isActive()) em.getTransaction().rollback();
			em.close();
	
	}

	}

}
